package com.shqcjd.yunweiyanoperator.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.shqcjd.yunweiyanoperator.R;
import com.shqcjd.yunweiyanoperator.util.ToastUtils;

public class AddTipDialog extends Dialog {
    private Button btn_dialog_add, btn_dialog_cancle;
    private TextView tv_title, et_dialog_staff_name;
    private Context context;
    private setOnClickDialogListener listener;

    public void setOnClickDialogListener(setOnClickDialogListener listener){
        this.listener = listener;
    }

    public AddTipDialog(@NonNull Context context) {
        super(context);
        this.context = context;
    }

    public AddTipDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected AddTipDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_add_tip);
        getWindow().setBackgroundDrawableResource(R.color.transparent);
        btn_dialog_add = findViewById(R.id.btn_dialog_add);
        btn_dialog_cancle = findViewById(R.id.btn_dialog_cancle);
        tv_title = findViewById(R.id.tv_title);
        et_dialog_staff_name = findViewById(R.id.et_dialog_staff_name);

        btn_dialog_add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    if(listener!=null){
                        listener.onClickAdd();
                    }
            }
        });

        btn_dialog_cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public void setStr(String titleStr, String contentStr, String btnStr){
        tv_title.setText(titleStr);
        et_dialog_staff_name.setText(contentStr);
        btn_dialog_add.setText(btnStr);
    }

    public interface setOnClickDialogListener{
        void onClickAdd();
    }
}
